﻿package com.urbansquall.display
{
	
import flash.display.Sprite;
import flash.events.Event;
	
public class InitializedSprite extends Sprite
{
	public function InitializedSprite()
	{
		if( this.stage != null )
		{
			init();
		}
		else
		{
			addEventListener( Event.ADDED_TO_STAGE, doInit );
		}
	}
	
	private function doInit( a_event : Event ) : void
	{
		removeEventListener( Event.ADDED_TO_STAGE, doInit );
		
		init();
	}
	
	protected function init() : void
	{
		throw new Error( "InitializedSprite. Override the subclasses' init. That's the whole point of InitializedSprite." );
	}
}
	
}